﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace DIT.Domain
{
    public class HUFAccount : Account
    {
        public HUFAccount(AccountTypeENUM _AccountType, string _PAN, HUFAccountInfo _PersonalInfo)
            : base(_AccountType, TaxPayerTypeENUM.HUF, _PAN, _PersonalInfo)
        {
        }

        public HUFAccount(DataRow row) : this
            (
                (AccountTypeENUM)Enum.Parse(typeof(AccountTypeENUM), row["AccountType"] + string.Empty)
              , row["PAN"] + string.Empty,
                new HUFAccountInfo
                (
                    new AssesseeName(Convert.IsDBNull(row["SurNameOrOrgName"]) ? null : row["SurNameOrOrgName"] + string.Empty
                                   , Convert.IsDBNull(row["FirstName"]) ? null : row["FirstName"] + string.Empty
                                   , Convert.IsDBNull(row["MiddleName"]) ? null : row["MiddleName"] + string.Empty
                                   , Convert.IsDBNull(row["OrgOldName"]) ? null : row["OrgOldName"] + string.Empty)
                  , new Address(Convert.IsDBNull(row["ResidenceNo"]) ? null : row["ResidenceNo"] + string.Empty
                              , Convert.IsDBNull(row["LocalityOrArea"]) ? null : row["LocalityOrArea"] + string.Empty
                              , Convert.IsDBNull(row["CityOrTownOrDistrict"]) ? null : row["CityOrTownOrDistrict"] + string.Empty
                              , Convert.IsDBNull(row["StateCode"]) ? null : (StateCodeENUM?)Enum.Parse(typeof(StateCodeENUM), row["StateCode"] + string.Empty)
                              , Convert.IsDBNull(row["PinCode"]) ? null : (ulong?)Convert.ToUInt64(row["PinCode"])
                              , Convert.IsDBNull(row["ResidenceName"]) ? null : row["ResidenceName"] + string.Empty
                              , Convert.IsDBNull(row["RoadOrStreet"]) ? null : row["RoadOrStreet"] + string.Empty
                              , Convert.IsDBNull(row["STDcode"]) ? null : (ulong?)Convert.ToUInt64(row["STDcode"])
                              , Convert.IsDBNull(row["PhoneNo"]) ? null : (ulong?)Convert.ToUInt64(row["PhoneNo"]))
                  , Convert.IsDBNull(row["DOB"]) ? null : (DateTime?)DateTime.Parse(row["DOB"] + string.Empty)
                  , Convert.IsDBNull(row["MobileNo"]) ? null : (ulong?)Convert.ToUInt64(row["MobileNo"])
                )
                {
                    EmailAddress = Convert.IsDBNull(row["EmailAddress"]) ? null : row["EmailAddress"] + string.Empty
                }
            )
        {
        }

        public static HUFAccount Sample
        {
            get
            {
                return new HUFAccount
                    (
                        AccountTypeENUM.TaxPayer
                      , "APGPG6398S",
                        new HUFAccountInfo
                        (
                            new AssesseeName("Gupta", "Biswa", "Nath", null)
                          , new Address("30/37", "Barisha", "KOLKATA", StateCodeENUM.WB, 700008, "My Home", "Kailash Ghosh Road", 33, 24943701)
                          , new DateTime(1942, 8, 30)
                          , 9989908101
                        )
                        {
                            EmailAddress = "bijit_0007.jobs@yahoo.com"
                        }
                    );
            }
        }

        public static HUFAccount Default
        {
            get
            {
                return new HUFAccount
                    (
                        AccountTypeENUM.TaxPayer
                      , "APGKH8370Q",
                        new HUFAccountInfo
                        (
                            new AssesseeName("Gupta", null, null, null)
                          , new Address("30/37", "Barisha", "KOLKATA", StateCodeENUM.WB, 700008, null, null, null, null)
                          , new DateTime(1942, 8, 30)
                          , 9989908101
                        )
                    );
            }
        }
    }
}
